package com.bytedance.scenedemo.dialog;

import com.bytedance.scene.Scene;
import com.bytedance.scene.dialog.bottomsheet.Gravity;
import com.bytedance.scene.navigation.NavigationSceneGetter;
import com.bytedance.scenedemo.ResourceTable;
import com.bytedance.scenedemo.utility.ColorUtil;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.StackLayout;
import ohos.agp.components.Text;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.Color;
import ohos.agp.utils.LayoutAlignment;
import ohos.agp.utils.TextAlignment;

/**
 * Created by JiangQi on 8/8/18.
 */
public class DemoDialogScene extends Scene {
    @Override
    public Component onCreateView(LayoutScatter scatter, ComponentContainer container, Intent intent) {
        StackLayout layout = new StackLayout(requireSceneContext());
        Text text = new Text(requireSceneContext());
        text.setTextAlignment(TextAlignment.TOP);
        text.setTextSize(12, Text.TextSizeType.FP);
        text.setMultipleLine(true);
        String history = NavigationSceneGetter.requireNavigationScene(this).getStackHistory();
        text.setText(history);
        StackLayout.LayoutConfig layoutConfig = new StackLayout.LayoutConfig(600,600);
        layoutConfig.alignment = LayoutAlignment.CENTER;
        text.setBackground(ColorUtil.getMaterialColor(1));
        layout.addComponent(text,layoutConfig);

        Component cptClick=new Component(requireSceneContext());
        cptClick.setClickedListener(component -> {
            if(this.getApplicationContext()!=null){
                NavigationSceneGetter.requireNavigationScene(this).pop();
            }
        });
        layout.addComponent(cptClick,new StackLayout.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT));
        return layout;
    }
}
